#!/bin/sh
if [ -z $1 ];then
hive_db=default
else
hive_db=$1
fi

if [ -z $2 ];then
create_time=`date  "+%Y-%m-%d %H-%M-%S"`
else
create_time=$2
fi

hiveconfig=$(cat <<"EOF" /home/hdfs/parquet_shell/hive_parquet_scripts/hive.config
EOF
)

sql_suffix=$(cat <<EOF
        INSERT INTO TABLE dongfeng.d007 PARTITION (part_time) SELECT latitude,longitude,originalLat,originalLng,height,direction,gpsDate,accelerator,driverRequestEngineMode,rotation,engineOutputTorque,transmissionOutputShaftRotation,clutchSlipRatio,transmissionInputShaftRotation,transmissionSystemCombinedState,gear,gearboxMode1,gearboxMode2,gearboxMode3,gearboxMode4,gearboxRequestGear,speed,totalMileage,exhaustBrakingState,fuelConsumption,instantaneousFuelConsumption,averageFuelConsumption,temporaryManualRequest,brake,cruiseActivation,parkingBrake,leftFrontWheelRotation,rightFrontWheelRotation,ABSActivation,rampStartSwitch,atmosphericPressure1,atmosphericTemperature,airPressure,quality,ramp,transmissionOilTemperature,clutchOffset,clutchWearPercentage,clutchTemperature,clutchNipPoint,terminalId,'${create_time}',part_time FROM dongfeng.d007_temp;
EOF
)
sql="${hiveconfig}${sql_suffix}"
############  execute begin   ###########
hive -e  "$sql"
#echo $sql
